import React, { Component } from "react";
import { NavLink, Route, Switch } from "react-router-dom";
import A from "./A";
import B from "./B";
import C from "./C";
export default class Home extends Component {
  handlePush = () => {
    this.props.history.push("/login");
  };
  render() {
    return (
      <div>
        <h3>嵌套路由</h3>
        <NavLink to="/home/a">A</NavLink>
        <NavLink to="/home/b">B</NavLink>
        <NavLink to="/home/c">C</NavLink>
        &nbsp;<button onClick={this.handlePush}>跳转到login界面</button>
        <hr />
        <Switch>
          <Route path="/home/a" component={A}></Route>
          <Route path="/home/b" component={B}></Route>
          <Route path="/home/c" component={C}></Route>
        </Switch>
      </div>
    );
  }
}
